package com.ronghuanet;

import com.ronghuanet.user.interceptor.LoginInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@MapperScan("com.ronghuanet.*.mapper")
@EnableCaching
public class CarAppStart implements WebMvcConfigurer {
    public static void main(String[] args) {

        // 启动一个内置tomcat，并且会管理spring容器
        SpringApplication.run(CarAppStart.class, args);
    }


    @Autowired
    private LoginInterceptor loginInterceptor;
    //添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        /*registry.addInterceptor(loginInterceptor)
                //放行地址
                .excludePathPatterns("/logininfo/account")
                .excludePathPatterns("/user/register/**")
                .excludePathPatterns("/validateCode/**")
                .excludePathPatterns("/fastDfs")
                .excludePathPatterns("/webjars/**")    //swagger界面相关也要放行
                .excludePathPatterns("/swagger-resources/**")
                .excludePathPatterns("/v2/api-docs")
                .excludePathPatterns("/swagger-ui.html");*/
    }

    static {
        System.setProperty("es.set.netty.runtime.available.processors", "false");
    }
}
